package view.render.monster
{
	import enums.main.UISize;
	
	import feathers.controls.Label;
	
	import model.vo.monster.LMonsterItemEffectVo;
	
	import starling.text.TextField;
	import starling.utils.Color;
	
	import view.render.BaseItem;
	
	
	/**
	 * 大型怪物-道具效果列表item
	 * @author £iang
	 * 
	 */	
	public class LMonsterItemListItem extends BaseItem
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** 道具效果信息  */
		public var itemEffectLabel:Label;
		/** 备考信息  */
		public var referenceLabel:TextField;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 初始化函数 
		 * 
		 */		
		override protected function initializeOther():void
		{
			itemEffectLabel = new Label();
			itemEffectLabel.textRendererProperties.wordWrap = true;
			this.addChild( itemEffectLabel );
			
			referenceLabel = new TextField(
				UISize.MAIN_W * 0.6, 
				_itemH * UISize.DPI_SCALE,
				"", "微软雅黑,宋体", 24 * UISize.DPI_SCALE, Color.WHITE
			);
			referenceLabel.vAlign = "center";
			referenceLabel.hAlign = "left";
			this.addChild( referenceLabel );
		}
		
		/**
		 * 调整组件 
		 * 
		 */		
		override protected function draw():void
		{
			var labelY:Number = ( _itemH - 
				43 ) / 2 * UISize.DPI_SCALE;
			var padding:Number = UISize.TITLE_PADDING_LEFT * UISize.DPI_SCALE;
			var firstLabelFullW:Number;
			
			firstLabel.x = padding;
			firstLabelFullW = UISize.MAIN_W * _firstPercent;
			
			itemEffectLabel.y = labelY;
			itemEffectLabel.x = UISize.MAIN_W / 4;
			itemEffectLabel.width  = UISize.MAIN_W * 0.15;
			
			referenceLabel.x = UISize.MAIN_W * 0.4;
			referenceLabel.width = UISize.MAIN_W * 0.6;
			
			this.width = UISize.MAIN_W;
			this.height = _itemH * UISize.DPI_SCALE;
		}
		
		/**
		 * 设置item数据 
		 * @param data 数据
		 * 
		 */		
		public function setData( data:LMonsterItemEffectVo ):void
		{
			firstLabel.text = data.itemName;
			itemEffectLabel.text = data.itemEffect;
			referenceLabel.text = data.reference;
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 析构函数
		 * 
		 */		
		protected override function disposeOther():void
		{
			disposeLabels( [
				"itemEffect", "reference"
			] );
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function LMonsterItemListItem()
		{
			super();
			_itemH = UISize.LMONSTER_IE_ITEM_H;
			_firstPercent = 0.25;
			initialize();
		}
	}
}